package com.snimay.app.entity.vo;

import java.util.Set;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.snimay.app.menu.vo.Menu;
import com.snimay.heibernate.Annotation.field;
import com.snimay.heibernate.Annotation.table;

/**   
 * @Title      : Entity.java
 * @Package    : com.snimay.app.entity.vo
 * @Description: TODO 
 * @author     : xxy
 * @date       : 2018年5月29日 下午12:03:56
 * @version    : V1.0   
 */
@table(query = "${query}", name = "${name}",size=10,sever= "${sever}")
@javax.persistence.Entity
@Table(name = "SYS_${name}")
public class ${name} {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@field(text = "ID")
	public Long id;
	
	<#list fields! as field> 
		<#if field.type="string">
			@field(text = "${field.text}",regex="",vfield="",length=100,index=3)
			public String ${field.name};
		<#elseif field.type="int">
			@field(text = "${field.text}",regex="",vfield="",length=100,index=1)
			public int ${field.name};
		<#elseif field.type="text">
			@field(text = "${field.text}",regex="",vfield="",length=100,index=4)
			public String ${field.name};
		<#elseif field.type="float">
			@field(text = "${field.text}",regex="",vfield="",length=100,index=2)
			public float ${field.name};
		<#elseif field.type="date">
			@field(text = "${field.text}",regex="",vfield="",length=100,index=5)
			public Date ${field.name};		
		<#elseif field.type="obj">
			@field(text="${field.text}",vfield="${field.clazzQuery}",index=6)
			@ManyToOne(cascade = CascadeType.ALL)  
			public Menu data;
		<#elseif field.type="list">
			@field(text="${field.text}",index=7)
			@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)  
			@JoinColumn(insertable=true,updatable=true,name="${name}")
		    public Set<${field.clazz}> ${field.name};
		<#else>
			//@field(text="${field.text}",vfield="${field.clazzQuery}",index=1)
			//public ${field.clazz} ${field.name};
		</#if>
	</#list>
}